<?php

use App\Models\WorkOrder\WorkOrderUserRoleModel;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateWorkOrderManagerTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('work_order_apply_manager', function (Blueprint $table) {
            $table->id();
            $table->string('workOrderNo', 32)->default('')->comment('工单号');
            $table->unsignedTinyInteger('status')->default(0)->comment('处理状态 0-正常  1-关闭');
            $table->unsignedTinyInteger('role')
                  ->default(0)
                  ->comment('负责人类型 ' . enumToMigrationComment(WorkOrderUserRoleModel::ROLE_TYPE_TEXT));

            $table->unsignedInteger('managerId')->default(0)->comment('负责人用户id');
            $table->string('managerName', 32)->default('')->comment('负责人姓名');
            $table->text('remark')->default('')->comment('备注');
            $table->text('solution')->default('')->comment('解决方案');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->unsignedTinyInteger('isDeleted')->default(0);
            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '工单 - 工单负责人映射表';

            $table->index('workOrderNo', 'idx_workOrderNo');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('work_order_apply_manager');
    }
}
